//
//  EmoticonAttachement.swift
//  XinLangWeibo10
//
//  Created by 白利兵 on 15/11/2.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class EmoticonAttachement: NSTextAttachment {
    // 表情模型
    var emoticon: Emoticon?
    func imageText(font: UIFont) -> NSAttributedString {
        image = UIImage(named: (self.emoticon!.imagePath))
        bounds = CGRectMake(0, -4, font.lineHeight, font.lineHeight)
        // 转换成属性文本
        let imageText = NSAttributedString(attachment: self)
        // `添加`字体 - UIKit.framework 第一个头文件
        return imageText
    }
    init(emoticon: Emoticon) {
        self.emoticon = emoticon
        super.init(data: nil, ofType: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
